package com.project.controller;

import com.project.entity.Member;
import com.project.entity.RestPOJO;
import com.project.service.MemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Api(tags="用户余额管理相关")
@RestController
public class MemberController {

    @Autowired
    private MemberService memberService;

    @ApiOperation(
            value = "修改用户的余额",
            httpMethod = "PUT",
            protocols = "HTTP",
            produces = "application/json",
            response = RestPOJO.class,
            notes = "修改用户余额"
    )
    @PutMapping("/member")
    public RestPOJO updMember(@RequestBody Member member){
        int a = memberService.updMemberByUid(member);
        RestPOJO rest = new RestPOJO();
        if (a > 0){
            rest.setStatus(1000);
            rest.setMessages("修改成功");
        }
        else {
            rest.setStatus(1001);
            rest.setMessages("修改失败");
        }
        return rest;
    }
}
